package miku.firstgame.ui.component
{
	import feathers.controls.ScrollText;

	public class MessageOutput extends ScrollText
	{
		public function MessageOutput()
		{
			super();
			this.isHTML = true;
		}

		/*
		var fontHeader:String = "";
		var fontTail:String = "";

		if (b)
		{
		fontHeader = "<b>";
		fontTail = "</b>";
		}
		if (i)
		{
		fontHeader = "<i>" + fontHeader;
		fontTail += "</i>";
		}
		if (u)
		{
		fontHeader = "<u>" + fontHeader;
		fontTail += "</u>";
		}

		fontHeader = "<font face='" + font + "' color='" + color + "' size='" + size + "'>" + fontHeader;
		fontTail += "</font>";
		*/

		public function appendMessage(name:String, message:String):void
		{
			this.text += getColorString(0x191afa, "[" + name + "]:") + getColorString(0x14ce4d, message);
		}

		public function newLine():void
		{
			this.text += "<br/>";
		}

		public function appendSysMessage(message:String):void
		{
			this.text += getColorString(0xdee518, message);
		}

		protected function getColorString(color:uint, value:String):String
		{
			return "<font size='14' color='#" + color.toString(16) + "' >" + value + "</font>";
		}

		public function scrollToBottom():void
		{
			this.verticalScrollPosition = this.maxVerticalScrollPosition;
		}
	}
}
